package com.sooth.micro.business.controller;

import com.sooth.common.core.domain.R;
import com.sooth.common.web.core.BaseController;
import com.sooth.micro.business.service.IMicroBusinessService;
import com.sooth.micro.business.view.QueryBo;
import com.sooth.micro.business.view.QueryVo;
import com.sooth.micro.business.view.RemoveBo;
import com.sooth.micro.business.view.SaveBo;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/micro/business")
public class MicroBusinessController extends BaseController {
    private final IMicroBusinessService microCodeService;

    @PostMapping("/list")
    public R<Object> list(@RequestBody QueryVo queryVo) {
        return R.ok(microCodeService.list(queryVo));
    }

    @PostMapping("/remove")
    public R<Void> remove(@RequestBody RemoveBo removeBo) {
        return toAjax(microCodeService.remove(removeBo));
    }

    @PostMapping("/query")
    public R<Object> query(@RequestBody QueryBo queryBo) {
        return R.ok(microCodeService.query(queryBo));
    }

    @PostMapping("/save")
    public R<Void> save(@RequestBody SaveBo saveBo) {
        microCodeService.save(saveBo);
        return R.ok();
    }
}
